package dhm.com.hpx.activity;

        import android.view.View;
        import android.webkit.WebChromeClient;
        import android.webkit.WebSettings;
        import android.webkit.WebView;
        import android.webkit.WebViewClient;
        import android.widget.ProgressBar;

        import butterknife.BindView;
        import butterknife.ButterKnife;
        import dhm.com.hpx.R;
        import dhm.com.hpx.base.BaseActivity;
        import dhm.com.hpx.base.netWork.Constant;

public class WebActivity extends BaseActivity {

    @BindView(R.id.ticker_progress)
    ProgressBar tickerProgress;
    @BindView(R.id.ticket_wb)
    WebView ticketWb;
    private String type;

    @Override
    protected int getLayout() {
        return R.layout.activity_web;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        type = getIntent().getStringExtra("type");

        WebSettings webSettings = ticketWb.getSettings();
        webSettings.setUseWideViewPort(true);//是否支持双击缩放网页操作(wap网页不支持)
        webSettings.setJavaScriptEnabled(true);//是否支持JavaScript



        ticketWb.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                //设置加载进度条
                view.setWebChromeClient(new WebChromeClient() {
                    @Override
                    public void onProgressChanged(WebView view, int progress) {
                        if (tickerProgress != null) {
                            tickerProgress.setProgress(progress);
                            if (progress == 100) {
                                tickerProgress.setVisibility(View.GONE);
                            }else {
                                tickerProgress.setVisibility(View.VISIBLE);
                            }
                        }
                        super.onProgressChanged(view, progress);
                    }
                });
                return true;

            }
        });

        //加载网页
        if (type.equals("1")){
            //趣企客APP用户协议
            ticketWb.loadUrl(Constant.PATH+"appapi/information/user_agreement.html");
        }else {
            //趣企客APP隐私政策
            ticketWb.loadUrl(Constant.PATH+"appapi/information/user_policy.html");
        }


    }

    @Override
    protected void initData() {

    }
}
